import { createBrowserRouter, redirect } from "react-router-dom";
import Login from "../pages/login/index";
import Layout from "@/pages/layout/index";
import Home from "@/pages/home/index";
import AuthRouter from "@/components/AuthRouter";
import CreateAritle from "@/pages/createAritle/index";
import Article from "@/pages/arrtical";

const router = createBrowserRouter([
  {
    path: "/",
    // element: <Login/>,
    loader:()=>redirect("/login"),
  },
  {
    path: "/login",
    element: <Login/>,
  },
  {
    path: "/layout",
    element:<AuthRouter><Layout/></AuthRouter>,
    children:[
      {
        index:true,
        // element:<Home/>
        loader:()=>redirect("/layout/home"),
      },
      {
        path:"home",
        element:<Home/>
      },
      {
        path:"artical",
        element:<Article/>
      },
      {
        path:"creatArcitle",
        element:<CreateAritle/>
      },
    ]
  },
  
]);

export default router;